// ==UserScript==
// @name         555x一键下载
// @namespace    https://gitee.com/fyhn/tampermonkey
// @version      1.2
// @description  555x.co小说网站一键下载，不需要多重跳转,去广告
// @author       fyhn
// @match        http://www.555x.co/html/*
// @match        http://www.555x.co/search.html
// @match        http://www.555x.co/search/*
// @match        https://www.555x.co/html/*
// @match        https://www.555x.co/search.html
// @match        https://www.555x.co/search/*
// @match        http://www.555x.co/shuku/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    var docs=document.querySelectorAll("li.qq_g a");
    for(var i=0;i<docs.length;i++){
        var doc=docs[i];
        var link=doc.getAttribute("href");
        //console.log(link.parentNode);
        doc.text=doc.text.replace("TXT下载","");
        var txtdownload=link.replace(/(http:\/\/www.555x.co)\/html\/.*?\/txt(.*?).html/ , "$1/home/down/txt/id/$2");
        var txtitem=document.createElement("a");
        var txtnode=document.createTextNode("TXT下载");
        txtitem.setAttribute("href",txtdownload);
        txtitem.setAttribute("class","txtdownload");
        txtitem.style.margin="0px 10px";
        txtitem.style.fontSize="16px";
        txtitem.appendChild(txtnode);
        doc.parentNode.insertBefore(txtitem,doc.nextSibling);

        //var zipdownload=link.replace(/(http:\/\/www.555x.co)\/html\/.*?\/zip(.*?).html/ , "$1/home/down/zip/id/$2");
        //var zipitem=document.createElement("a");
        //var zipnode=document.createTextNode("ZIP下载");
        //zipitem.setAttribute("href",zipdownload);
        //zipitem.setAttribute("class","zipdownload");
        //zipitem.style.margin="0px 10px";
        //zipitem.style.fontSize="16px";
        //zipitem.appendChild(zipnode);
        //doc.parentNode.insertBefore(zipitem,doc.nextSibling);
    }
    function adv_remove(){
        var adv=document.querySelectorAll("body > div")[1];
        if (typeof(adv) != "undefined"){
            adv.remove();
            clearInterval(id);
        }
    }
    id = setInterval(adv_remove,100);
})();